import React, { FC } from 'react'
import { useHistory } from 'react-router-dom'
import { openInWebview } from '@utils/appInfo'
import './index.less'

interface HeaderProps {
  title: string
  onBack?: () => void
}
const Header: FC<HeaderProps> = ({ title, onBack }) => {
  const history = useHistory()
  const isWebWiew = openInWebview()
  const back = () => {
    onBack?.() || history.goBack()
  }
  // isBrowser
  return (
    <section className={`stdHeader ${isWebWiew ? '' : 'isBrowser'}`}>
      <i className={'iconfont icon-fanhui'} onClick={back} />
      {title}
    </section>
  )
}

export default Header
